@extends('admin.base')

@section('content')
    <div class="layui-card">
        <div class="layui-card-header  layuiadmin-card-header-auto">
            <h2>为用户设置权限角色</h2>
        </div>
        <div class="layui-card-body">
            <form class="layui-form" action="/admin/api/user/{{$id}}/role" method="post">
                <div class="layui-form-item">
                    <label for="" class="layui-form-label">请选择：</label>
                    <div class="layui-input-block">
                        @foreach($dao as $key=>$val)
                            @if(isset($roles) && in_array($val->name,$roles))
                                <input type="checkbox" name="role[]" value="{{$val->id}}" title="{{$val->display_name}}" checked>
                            @else
                                <input type="checkbox" name="role[]" value="{{$val->id}}" title="{{$val->display_name}}" >
                            @endif
                        @endforeach
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button type="submit" class="layui-btn" lay-submit="" lay-filter="postForm">确 认</button>
                        <a  class="layui-btn" href="javascript:void(0)" id="close"  >关 闭</a>
                    </div>
                </div>
            </form>
        </div>
    </div>
@endsection

@section('script')
    <script>
        layui.use(['layer', 'form'], function(){
            let layer = layui.layer;
            let form = layui.form;

            @component('admin.ajax',['call'=>'close(true)'])

            @endcomponent

        });
    </script>
@endsection